package com.example.myapplication.ui.theme

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.rotate
import kotlin.math.min

@Composable
fun LakersThemedBackground(
    modifier: Modifier = Modifier,
    isDark: Boolean = false
) {
    val purple = if (isDark) LakersPurpleDark else LakersPurple
    val gold = if (isDark) LakersGoldDark else LakersGold
    val background = if (isDark) Color.Black else Color.White
    
    Canvas(modifier = modifier.fillMaxSize()) {
        // 绘制背景色
        drawRect(color = background)
        
        val canvasWidth = size.width
        val canvasHeight = size.height
        val minDimension = min(canvasWidth, canvasHeight)
        
        // 绘制科技感线条和形状
        drawLine(
            color = purple,
            start = Offset(0f, canvasHeight * 0.2f),
            end = Offset(canvasWidth, canvasHeight * 0.2f),
            strokeWidth = 2f
        )
        
        drawLine(
            color = gold,
            start = Offset(0f, canvasHeight * 0.8f),
            end = Offset(canvasWidth, canvasHeight * 0.8f),
            strokeWidth = 2f
        )
        
        // 绘制几何图形增加科技感
        rotate(degrees = 45f) {
            drawRect(
                color = purple.copy(alpha = 0.1f),
                topLeft = Offset(canvasWidth * 0.1f, canvasHeight * 0.1f),
                size = androidx.compose.ui.geometry.Size(
                    minDimension * 0.1f,
                    minDimension * 0.1f
                )
            )
        }
        
        rotate(degrees = -30f) {
            drawRect(
                color = gold.copy(alpha = 0.1f),
                topLeft = Offset(canvasWidth * 0.8f, canvasHeight * 0.7f),
                size = androidx.compose.ui.geometry.Size(
                    minDimension * 0.05f,
                    minDimension * 0.05f
                )
            )
        }
        
        // 绘制圆形装饰
        drawCircle(
            color = purple.copy(alpha = 0.05f),
            radius = minDimension * 0.2f,
            center = Offset(canvasWidth * 0.9f, canvasHeight * 0.1f)
        )
        
        drawCircle(
            color = gold.copy(alpha = 0.05f),
            radius = minDimension * 0.1f,
            center = Offset(canvasWidth * 0.2f, canvasHeight * 0.8f)
        )
    }
}